package demo;

import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-05-11
 * Time: 10:55
 */
public class demo2 {

    //1.
    public static void main1(String[] args) {
        char ch = 'a';
        for (int i = 0; i < 26; i++) {
            System.out.print((char) (ch + i) + " ");
        }
    }

    //2.
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        Random random = new Random();
        int num = random.nextInt(1, 100);
        while (true) {
            System.out.println("请输入一个数字");
            int input = in.nextInt();
            if (input > num) {
                System.out.println("猜大了");
            } else if (input < num) {
                System.out.println("猜小了");
            } else {
                System.out.println("猜对了");
                break;
            }
        }
    }

    //3.
    public static void main3(String[] args) {
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println();
        int[] b = new int[a.length];
        for (int j = 0; j < a.length; j++) {
            b[j] = a[j] + 1;
        }
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }
    }

    //4.
    public static void main(String[] args) {
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        System.out.println("数组的引用:" + a);
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }
    }

}
